"""
selenium 文件上传:
    input 的文件上传:
        定位到 input , send_keys() 指定上传的文件即可 .

    其他文件上传:
        AutoIt ( 基本适用所有文件上传 )
        这个方法需要编写脚本 , 通过 Python 加载命令方式来实现文件上传 .

"""
import pytest
from selenium.webdriver.common.by import By
from os.path import dirname, join
from basic.s1_pytest_base import TestBase


class TestUpload(TestBase):

    def test_oo1(self):
        """
        百度图片的图片上传
        """
        self.driver.get('https://image.baidu.com/')
        img_file = join(dirname(__file__), 'bamboo.jpg')
        self.driver.find_element(By.CSS_SELECTOR, '.st_camera_off').click()
        ele_upload = self.driver.find_element(By.CSS_SELECTOR, '#stfile')
        ele_upload.send_keys(img_file)


if __name__ == '__main__':
    pytest.main(['-vs', 's11_upload.py'])
